package app.mvc.view.layers
{
	import alternativa.gui.base.GUIobject;
	import alternativa.gui.container.Container;
	import alternativa.gui.keyboard.IKeyboardListener;
	import alternativa.gui.keyboard.KeyFiltersConfig;
	import alternativa.gui.keyboard.KeyboardManager;
	import alternativa.gui.layout.IStageSizeListener;
	
	import app.mvc.Notifications;
	import app.mvc.model.keyboards.ObjectLayerKeyFilter;
	import app.mvc.view.components.dragDrop.DropLayer;
	
	import flash.display.Sprite;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.ui.Keyboard;
	
	import org.puremvc.as3.patterns.facade.Facade;
	
	import utils.UtilsGC;
	
	/**
	 * 物件层(用来拖入控件，摆放位置等)
	 * @author xiling
	 */
	public class ObjectsLayer extends Container implements IStageSizeListener,IKeyboardListener
	{
		/**
		 * 可拖放层
		 * @default 
		 */
		public var dropLayer:DropLayer;
		
		private var keyConfig:KeyFiltersConfig;
		private var keyFilter:ObjectLayerKeyFilter;
		
		public function ObjectsLayer()
		{
			super();
			
			init();
		}
		
		public function clearAll():void
		{
			UtilsGC.clearChildren(dropLayer);
		}
		
		private function init():void
		{
			dropLayer = new DropLayer();
			addChild(dropLayer);
			
			keyConfig = new KeyFiltersConfig();
			keyFilter = new ObjectLayerKeyFilter();
			keyConfig.addKeyDownFilter(keyFilter,"onKeyDown");
			keyConfig.addKeyUpFilter(keyFilter,"onKeyUp");
			keyConfig.bindKeyDownAction("onKeyDown",keyFilter,keyFilter.onKeyDown);
			keyConfig.bindKeyUpAction("onKeyUp",keyFilter,keyFilter.onKeyUp);
			KeyboardManager.addKeyboardListener(this);
		}

		
		override protected function draw():void
		{
			// TODO Auto Generated method stub
			super.draw();
			dropLayer.resize(width,height);
		}
		
		public function get keyFiltersConfig():KeyFiltersConfig
		{
			// TODO Auto Generated method stub
			return keyConfig;
		}
	}
}